package com.joysuch.wwyt.bp.entity.change;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * 变更记录
 */

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "wwyt_bp_change_record")
@SQLDelete(sql="update wwyt_bp_change_record set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql="update wwyt_bp_change_record set DELETE_FLAG = '1' where id= ?")
@Where(clause="DELETE_FLAG = '0'")
@Data
public class BpChangeRecord implements Serializable {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Long id;

    @ApiModelProperty("变更类型")
    private String changeType;

    @ApiModelProperty("变更子类型")
    private String changeSubType;

    @ApiModelProperty("变更项目")
    private String changeItem;

    @ApiModelProperty("变更项目ID")
    private Long changeItemId;

    @ApiModelProperty("变更项目子类型ID")
    private Long changeItemSubId;

    @ApiModelProperty("变更操作")
    private String changeOperation;

    @ApiModelProperty("变更子类型操作")
    private String changeSubOperation;

    @ApiModelProperty("变更申请人")
    private Long applyUserId;

    @ApiModelProperty("变更申请人部门ID")
    private Long applyDepartId;

    @ApiModelProperty("变更申请人岗位ID")
    private Long applyJobId;

    @ApiModelProperty("变更危害识别与风险评估")
    private String riskEvalResult;

    @ApiModelProperty("变更申请时间")
    private Date applyDate;

    @ApiModelProperty("变更内容")
    private String changeDetails;

    @ApiModelProperty("变更数据 json")
    private String changeData;

    @ApiModelProperty("变更原因")
    private String changeReason;

    @ApiModelProperty("变更 风险分析与控制措施")
    private String riskAnalysis;

    @ApiModelProperty("变更状态： 1=待审核，2=审核通过，3=审核不通过")
    private Integer state;

    @ApiModelProperty("变更 审批人")
    private Long approveUserId;

    @ApiModelProperty("变更 审批部门")
    private Long approveDepartId;

    @ApiModelProperty("变更 审批时间")
    private Date approveDate;


    // 通用字段
    @org.springframework.data.annotation.CreatedBy
    @ApiModelProperty("创建人")
    private Long createBy;

    @org.springframework.data.annotation.CreatedDate
    @ApiModelProperty("创建时间")
    private Date createTime;

    @org.springframework.data.annotation.LastModifiedBy
    @ApiModelProperty("更新人")
    private Long updateBy;

    @org.springframework.data.annotation.LastModifiedDate
    @ApiModelProperty("更新时间")
    private Date updateTime;

    @ApiModelProperty("租户")
    private Long tenentId;

    @ApiModelProperty("组织机构代码")
    private String orgCode;

    @ApiModelProperty("删除标记")
    private String deleteFlag;


}
